<?php
	require_once("../conexion/conexion.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />
<script src="../include_js/jquery.js" type="text/javascript"></script>

<style>
.filaPar
{
	background:#81D371; 
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
.filaImpar
{
	background:#AEF1A1;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
</style>
<script>
function CargaDetalle(valor)
{
	id = document.getElementById("tablaFactura").rows[valor].cells[0].innerText;
	//cliente = document.getElementById("tablaFactura").rows[valor].cells[1].innerText;
	factura = document.getElementById("tablaFactura").rows[valor].cells[2].innerText;
	doc = document.getElementById("tablaFactura").rows[valor].cells[5].innerText;
	pago = document.getElementById("tablaFactura").rows[valor].cells[6].innerText;
	//alert("factura "+factura+" doc "+doc);
	window.open("Contabilidad/VentanaResumenHistorico.php?fac="+factura+"&doc="+doc+"&id="+id+"&pago="+pago,"VentanaResumenHistorico","width=750,height=400,scrollbars=yes");
}
</script>
</head>

<body>
<form name="form_historico_lista" id="form_historico_lista" method="post">
<?php
	extract($_POST);
	$acum = 0;
	$acum2 = 0;
	//factura
	if ($txtFactura=="")
	{
		$txtFactura="null";
		$acum++;
	}
	else
	{$txtFactura="'".$txtFactura."'";}
	//cliente
	if ($cmb_Cliente==0) {
		$cmb_Cliente="null";
		$acum++;
	}
	//banco
	if ($cmb_Banco==0) {
		$cmb_Banco="null";
		$acum++;
	}
	else
	{$acum2=1;}
	//fecha inicial
	if ($txtFIni=="")
	{
		$txtFIni="null";
		$acum++;
	}
	else
	{
		$FechaIni = explode("-", $txtFIni);
		$txtFIni = "$FechaIni[2]-$FechaIni[1]-$FechaIni[0]";
	}
	//fecha final
	if ($txtFFin=="")
	{
		$txtFFin="null";
		$acum++;
	}
	else
	{
		$FechaFin = explode("-", $txtFFin);
		$txtFFin = "$FechaFin[2]-$FechaFin[1]-$FechaFin[0]";
	}
	
	if($acum != 5)
	{
		if($acum2 != 1)
		{
		//deposito
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql = "select
				DepCod,
				CliRSocial,
				DepFactura,
				DepMonto,
				date_format(DepFecha,'%d/%m/%Y') as fecha,
				DepDoc
				from deposito
				inner join clientes on
				clientes.CliRut=deposito.CliRut
				
				where 
				(($txtFactura is NULL) or (DepFactura = $txtFactura)) and
				((".$cmb_Cliente." is NULL) or (deposito.CliRut = '".$cmb_Cliente."')) and
				((($txtFIni is NULL) and ($txtFFin is NULL)) or DATE(DepFecha) BETWEEN '".$txtFIni."' and '".$txtFFin."')";		
		$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$con->cerrarBD();
		$fila = mysql_num_rows($res);
		//efectivo
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql2 = "select
				EfectivoCod,
				CliRSocial,
				EfectivoFactura,
				EfectivoMonto,
				date_format(EfectivoFecha,'%d/%m/%Y') as fecha,
				EfectivoDoc
				from efectivo
				inner join clientes on
				clientes.CliRut=efectivo.CliRut
				
				where 
				(($txtFactura is NULL) or (EfectivoFactura = $txtFactura)) and
				((".$cmb_Cliente." is NULL) or (Efectivo.CliRut = '".$cmb_Cliente."')) and
				((($txtFIni is NULL) and ($txtFFin is NULL)) or DATE(EfectivoFecha) BETWEEN '".$txtFIni."' and '".$txtFFin."')";		
		$res2= mysql_query($sql2) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$con->cerrarBD();
		$fila2 = mysql_num_rows($res2);
		//Transferencia
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql3 = "select
				TransCod,
				CliRSocial,
				TransFactura,
				TransMonto,
				date_format(TransFecha,'%d/%m/%Y') as fecha,
				TransDoc
				from transferencia
				inner join clientes on
				clientes.CliRut=transferencia.CliRut
				
				where 
				(($txtFactura is NULL) or (TransFactura = $txtFactura)) and
				((".$cmb_Cliente." is NULL) or (transferencia.CliRut = '".$cmb_Cliente."')) and
				((($txtFIni is NULL) and ($txtFFin is NULL)) or DATE(TransFecha) BETWEEN '".$txtFIni."' and '".$txtFFin."')";		
		$res3= mysql_query($sql3) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$con->cerrarBD();
		$fila3 = mysql_num_rows($res3);
		//cheques
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql4 = "select
				ChequeCod,
				CliRSocial,
				ChequeFactura,
				ChequeMonto,
				date_format(ChequeFecha,'%d/%m/%Y') as fecha,
				ChequeDoc
				from cheques
				inner join clientes on
				clientes.CliRut=cheques.CliRut
				
				where 
				(($txtFactura is NULL) or (ChequeFactura = $txtFactura)) and
				((".$cmb_Cliente." is NULL) or (cheques.CliRut = '".$cmb_Cliente."')) and
				((($txtFIni is NULL) and ($txtFFin is NULL)) or DATE(ChequeFecha) BETWEEN '".$txtFIni."' and '".$txtFFin."')";		
		$res4= mysql_query($sql4) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$con->cerrarBD();
		$fila4 = mysql_num_rows($res4);
		//vale vista
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql5 = "select
				ValCod,
				CliRSocial,
				ValFactura,
				ValMonto,
				date_format(ValFecha,'%d/%m/%Y') as fecha,
				ValDoc
				from valevista
				inner join clientes on
				clientes.CliRut=valevista.CliRut
				
				where 
				(($txtFactura is NULL) or (ValFactura = $txtFactura)) and
				((".$cmb_Cliente." is NULL) or (valevista.CliRut = '".$cmb_Cliente."')) and
				((($txtFIni is NULL) and ($txtFFin is NULL)) or DATE(ValFecha) BETWEEN '".$txtFIni."' and '".$txtFFin."')";		
		$res5= mysql_query($sql5) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$con->cerrarBD();
		$fila5 = mysql_num_rows($res5);
		echo "Deposito: ".$fila." Efectivo: ".$fila2." Transferencia: ".$fila3." Cheque: ".$fila4." ValeVista: ".$fila5;
		if(($fila >0)or($fila2 >0)or($fila3 >0)or($fila4 >0)or($fila5 >0))
		{?>
		<div class='option2'><label style="font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;">D: Dep&oacute;sito&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CH: Cheque&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;E: Efectivo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: Transferencia&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;V: Vale Vista</label></div>
			<table width="100%" border="0" class="uno" cellpadding="0" cellspacing="0" id="tablaFactura">
			<thead>
  			<tr>
				<th width="3%">id</th>
    			<th width="30%">Cliente</th>
    			<th width="14%">N&deg; Factura</th>
    			<th width="13%">Monto ($)</th>
    			<th width="11%" title="Fecha que se efectuo el ingreso del dinero.">Fecha</th>
    			<th width="12%">Documento</th>
				<th width="6%">Pago</th>
  		    	<th width="11%">&nbsp;</th>
  			</tr>
 			</thead>
			<?php
			$aux=1;
			$cont=1;
			//deposito
			while($reg = mysql_fetch_array($res))
			{
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"3%\" class=\"filaPar\" id=\"".$aux."\">".$reg['DepCod']."</td>";
					echo "<td width=\"30%\" class=\"filaPar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaPar\" id=\"".$aux."\">".$reg['DepFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaPar\" id=\"".$aux."\">$".number_format ($reg['DepMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaPar\" id=\"".$aux."\">".$reg['DepDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaPar\" id=\"".$aux."\">D</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"3%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['DepCod']."</td>";
					echo "<td width=\"30%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['DepFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaImpar\" id=\"".$aux."\">$".number_format ($reg['DepMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['DepDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaImpar\" id=\"".$aux."\">D</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				$aux++;
				$cont++;
			}
			//efectivo
			while($reg = mysql_fetch_array($res2))
			{
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"3%\" class=\"filaPar\" id=\"".$aux."\">".$reg['EfectivoCod']."</td>";
					echo "<td width=\"30%\" class=\"filaPar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaPar\" id=\"".$aux."\">".$reg['EfectivoFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaPar\" id=\"".$aux."\">$".number_format ($reg['EfectivoMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaPar\" id=\"".$aux."\">".$reg['EfectivoDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaPar\" id=\"".$aux."\">E</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"3%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['EfectivoCod']."</td>";
					echo "<td width=\"30%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['EfectivoFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaImpar\" id=\"".$aux."\">$".number_format ($reg['EfectivoMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['EfectivoDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaImpar\" id=\"".$aux."\">E</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				$aux++;
				$cont++;
			}
			//transferencia
			while($reg = mysql_fetch_array($res3))
			{
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"3%\" class=\"filaPar\" id=\"".$aux."\">".$reg['TransCod']."</td>";
					echo "<td width=\"30%\" class=\"filaPar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaPar\" id=\"".$aux."\">".$reg['TransFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaPar\" id=\"".$aux."\">$".number_format ($reg['TransMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaPar\" id=\"".$aux."\">".$reg['TransDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaPar\" id=\"".$aux."\">T</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"3%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['TransCod']."</td>";
					echo "<td width=\"30%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['TransFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaImpar\" id=\"".$aux."\">$".number_format ($reg['TransMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['TransDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaImpar\" id=\"".$aux."\">T</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				$aux++;
				$cont++;
			}
			//cheque
			while($reg = mysql_fetch_array($res4))
			{
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"3%\" class=\"filaPar\" id=\"".$aux."\">".$reg['ChequeCod']."</td>";
					echo "<td width=\"30%\" class=\"filaPar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaPar\" id=\"".$aux."\">".$reg['ChequeFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaPar\" id=\"".$aux."\">$".number_format ($reg['ChequeMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaPar\" id=\"".$aux."\">".$reg['ChequeDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaPar\" id=\"".$aux."\">CH</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"3%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['ChequeCod']."</td>";
					echo "<td width=\"30%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['ChequeFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaImpar\" id=\"".$aux."\">$".number_format ($reg['ChequeMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['ChequeDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaImpar\" id=\"".$aux."\">CH</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				$aux++;
				$cont++;
			}
			//vale vista
			while($reg = mysql_fetch_array($res5))
			{
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"3%\" class=\"filaPar\" id=\"".$aux."\">".$reg['ValCod']."</td>";
					echo "<td width=\"30%\" class=\"filaPar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaPar\" id=\"".$aux."\">".$reg['ValFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaPar\" id=\"".$aux."\">$".number_format ($reg['ValMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaPar\" id=\"".$aux."\">".$reg['ValDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaPar\" id=\"".$aux."\">V</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"3%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['ValCod']."</td>";
					echo "<td width=\"30%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['ValFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaImpar\" id=\"".$aux."\">$".number_format ($reg['ValMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['ValDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaImpar\" id=\"".$aux."\">V</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				$aux++;
				$cont++;
			}
			?>
			</table>
		<?php }
		else//else $fila,$fila2,$fila3, si es igual a 0
		{
			echo "<label style=\"font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;\">La b&uacute;squeda no gener&oacute; resultados.</label>";
		}
		}//cierra el if del $acum2
		else // else del $acum2 = 0, es decir se escogio algun banco
		{
		//cheques
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql = "select
				ChequeCod,
				CliRSocial,
				ChequeFactura,
				ChequeMonto,
				date_format(ChequeFecha,'%d/%m/%Y') as fecha,
				ChequeDoc
				from cheques
				inner join clientes on
				clientes.CliRut=cheques.CliRut
				
				where 
				(($txtFactura is NULL) or (ChequeFactura = $txtFactura)) and
				((".$cmb_Banco." is NULL) or (BancoCod = '".$cmb_Banco."')) and
				((".$cmb_Cliente." is NULL) or (cheques.CliRut = '".$cmb_Cliente."')) and
				((($txtFIni is NULL) and ($txtFFin is NULL)) or DATE(ChequeFecha) BETWEEN '".$txtFIni."' and '".$txtFFin."')";		
		$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$con->cerrarBD();
		$fila = mysql_num_rows($res);
		//vale vista
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql2 = "select
				ValCod,
				CliRSocial,
				ValFactura,
				ValMonto,
				date_format(ValFecha,'%d/%m/%Y') as fecha,
				ValDoc
				from valevista
				inner join clientes on
				clientes.CliRut=valevista.CliRut
				
				where 
				(($txtFactura is NULL) or (ValFactura = $txtFactura)) and
				((".$cmb_Banco." is NULL) or (BancoCod = '".$cmb_Banco."')) and
				((".$cmb_Cliente." is NULL) or (valevista.CliRut = '".$cmb_Cliente."')) and
				((($txtFIni is NULL) and ($txtFFin is NULL)) or DATE(ValFecha) BETWEEN '".$txtFIni."' and '".$txtFFin."')";		
		$res2= mysql_query($sql2) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$con->cerrarBD();
		$fila2 = mysql_num_rows($res2);
		echo "cheque: ".$fila." valevista: ".$fila2;
		if(($fila >0)or($fila2 >0))
		{?>
		<div class='option2'><label style="font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;">CH: Cheque&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;V: Vale Vista</label></div>
			<table width="100%" border="0" class="uno" cellpadding="0" cellspacing="0" id="tablaFactura">
			<thead>
  			<tr>
				<th width="3%">id</th>
    			<th width="30%">Cliente</th>
    			<th width="14%">N&deg; Factura</th>
    			<th width="13%">Monto ($)</th>
    			<th width="11%" title="Fecha que se efectuo el ingreso del dinero.">Fecha</th>
    			<th width="12%">Documento</th>
				<th width="6%">Pago</th>
  		    	<th width="11%">&nbsp;</th>
  			</tr>
 			</thead>
			<?php
			$aux=1;
			$cont=1;
			//cheque
			while($reg = mysql_fetch_array($res))
			{
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"3%\" class=\"filaPar\" id=\"".$aux."\">".$reg['ChequeCod']."</td>";
					echo "<td width=\"30%\" class=\"filaPar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaPar\" id=\"".$aux."\">".$reg['ChequeFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaPar\" id=\"".$aux."\">$".number_format ($reg['ChequeMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaPar\" id=\"".$aux."\">".$reg['ChequeDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaPar\" id=\"".$aux."\">CH</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"3%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['ChequeCod']."</td>";
					echo "<td width=\"30%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['ChequeFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaImpar\" id=\"".$aux."\">$".number_format ($reg['ChequeMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['ChequeDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaImpar\" id=\"".$aux."\">CH</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				$aux++;
				$cont++;
			}
			//vale vista
			while($reg = mysql_fetch_array($res2))
			{
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"3%\" class=\"filaPar\" id=\"".$aux."\">".$reg['ValCod']."</td>";
					echo "<td width=\"30%\" class=\"filaPar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaPar\" id=\"".$aux."\">".$reg['ValFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaPar\" id=\"".$aux."\">$".number_format ($reg['ValMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaPar\" id=\"".$aux."\">".$reg['ValDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaPar\" id=\"".$aux."\">V</td>";
					echo "<td width=\"11%\" class=\"filaPar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"3%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['ValCod']."</td>";
					echo "<td width=\"30%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"14%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['ValFactura']."</td>";
					echo "<td width=\"13%\" class=\"filaImpar\" id=\"".$aux."\">$".number_format ($reg['ValMonto'],0,',','.')."</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['fecha']."</td>";
					echo "<td width=\"12%\" class=\"filaImpar\" id=\"".$aux."\">".$reg['ValDoc']."</td>";
					echo "<td width=\"6%\" class=\"filaImpar\" id=\"".$aux."\">V</td>";
					echo "<td width=\"11%\" class=\"filaImpar\" id=\"".$aux."\"><a href=javascript:CargaDetalle($aux);>Ver Detalle</a></td>";
					echo "</tr>";
				}
				$aux++;
				$cont++;
			}
			?>
			</table>
		<?php }// fin del if $fila,$fila2
		else//else de cheque=0
		{
			echo "<label style=\"font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;\">La b&uacute;squeda no gener&oacute; resultados.</label>";
		}
		}//fin del else $acum2
	}
	else//else para cuando se halla presionado el boton sin escoger una opcion de busqueda
	{
		echo "<label style=\"font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;\">La b&uacute;squeda no gener&oacute; resultados.</label>";
	}
?>
</form>
</body>
</html>
